const app = getApp();
const Controller = require('../controllers/controllers.js').controller;
const util = require('../../utils/util.js');
Page({
  data: {
    isfixed:false,
    listsheight:20,
    currentDayList: [],
    historyList: []
  },
  onLoad() {
   this.loadData()
  },
  loadData(keyword){
    let _this = this
    Controller.case({
      'channel_alias': 'video',
      "apiList_1": `ekey=1&page=1&video_start_time=current&channel_alias=video&order_by=id`,
      "apiList_2": `ekey=2&page=1&video_start_time=history&channel_alias=video&order_by=id`,
    }).then(res => {
      let
      currentDayList = res.data.apiList[1],
      historyList = res.data.apiList[2]
      _this.setData({
        currentDayList,
        historyList
      });
      console.log(historyList.data)
    }).catch(res=>{
  
    })
  },
  onShow(){
 
  },
  
  onReachBottom(){
    
    
  },
  //页面滚动触发
  onPageScroll(event) {

    let scrollTop = event.scrollTop //页面滚动
    if (scrollTop >= this.data.listsheight) { //页面向上滚动indexKey
      this.setData({
        isfixed:true
      })
    } else { //页面向下滚动
      this.setData({
        isfixed:false
      })
    }
  },
  onShareAppMessage: function (e) {
    
  },
  onShareTimeline: function(res){
    
  },
  collectBtn(e){
    Controller.collect({
      "aid": e.currentTarget.dataset.id,
    }).then(res => {
      console.log(res.data)
      let categoryList = res.data.apiChannel[1]
      _this.setData({
        categoryList,
        productList
      });
      console.log(productList)
    }).catch(res=>{
    })
  },
  goDetail(e){
    let aid = e.currentTarget.dataset.id
    console.log(e.currentTarget.dataset)
    wx.navigateTo({
      url: `/pages/video/replay?id=${aid}`,
    })
  },
  goRoom(e){
    let aid = e.currentTarget.dataset.id
    console.log(e.currentTarget.dataset)
    wx.navigateTo({
      url: `/pages/video/detail?id=${aid}`,
    })
  },
  collectBtn(e){
    Controller.collect({
      "aid": e.currentTarget.dataset.id,
    }).then(res => {
      console.log(res.data)
      let categoryList = res.data.apiChannel[1]
      _this.setData({
        categoryList,
        productList
      });
      console.log(productList)
    }).catch(res=>{
  
    })
  },
})